package org.ipower.examsystem.service.impl;

import java.util.List;
import org.ipower.examsystem.dao.CatalogDao;
import org.ipower.examsystem.domain.Catalog;
import org.ipower.examsystem.domain.DataField;
import org.ipower.examsystem.service.CatalogService;
import org.ipower.platform.domain.Pager;
import org.ipower.platform.domain.QueryCondition;
import org.ipower.platform.service.TreeDataCollection;

/**
 * 考试科目服务实现类。
 * @author jeasonyoung
 */
public class CatalogServiceImpl implements CatalogService{
    private static final long serialVersionUID = 1L;
    private CatalogDao dao = null;
   
    @Override
    public void setCatalogDao(CatalogDao dao) {
        this.dao = dao;
    }
  
    @Override
    public Pager<Catalog> findAll(String ascProperty, boolean isAsc, int start, int limit, List<QueryCondition> entites) {
        return this.dao.findAll(ascProperty, isAsc, start, limit, entites);
    }
    
    @Override
    public void saveOrUpdate(Catalog data) {
        if(data != null){
            if(this.dao.load(data.getCatalogID()) == null){
                this.dao.save(data);
            }else{
                this.dao.update(data);
            }
        }
    }
    
    @Override
    public void delete(String catalogID){
        if(catalogID != null && !catalogID.isEmpty()){
            this.dao.delete(catalogID);
        }
    }
  
    @Override
    public List<DataField> NotSelfCatalog(String catalogID) {
        return this.dao.NotSelfCatalog(catalogID);
    }
    
    @Override
    public TreeDataCollection CatalogTree() {
       return this.dao.getCatalogs();
    }   
}